package inline;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Process;

public class PermissionUtils {
    public static int checkPermission(Context context, String permission) {
        if (permission == null) {
            throw new IllegalArgumentException("permission is null");
        }

        try {
            return context.checkPermission(permission, Process.myPid(), Process.myUid());
        } catch (Throwable throwable) {
            throwable.printStackTrace();
            if (Build.VERSION.SDK_INT >= 23) {
                return PackageManager.PERMISSION_DENIED;
            }
            return PackageManager.PERMISSION_GRANTED;
        }
    }
}
